package com.woniu.user.MqConfig;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class RabbitInitConfig {
    //创建交换机
    @Bean
    public Exchange exchange(){
        return new DirectExchange("config_exchange",true,false,null);
    }

    @Bean
    public Queue queueConfig1(){
        // 以下两种方式创建队列都是可以的
        return new Queue("comment", true, false, false, null);
    }

    @Bean
    public Binding bindingConfig2(@Qualifier("queueConfig1")Queue queue, Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("comment").noargs();
    }
}